package disease

import (
	"gitcode.com/G-YT/iHealth25/server/global"
	"gitcode.com/G-YT/iHealth25/server/model/health"
	"gitcode.com/G-YT/iHealth25/server/model/user"
	"time"
)

// 枚举从1开始

type Disease struct {
	ID     uint   `json:"id" gorm:"column:id;comment:id;"`
	Name   string `json:"name" gorm:"column:bz_name;comment:名称;"`
	BzlxID uint   `json:"bzlx_id" gorm:"column:bzlx_id;comment:病症类型id;"`
}

type DiseaseType struct {
	ID   uint   `json:"id" gorm:"primarykey;column:id;"`
	Name string `json:"name" gorm:"column:bzlx_name;comment:名称"`
}

// DiseaseReportRecord 病症报告记录struct
type DiseaseReportRecord struct {
	global.GVA_MODEL
	Uid          uint             `json:"uid" gorm:"column:uid;comment:用户ID"`
	ReportNumber string           `json:"report_number" gorm:"column:report_number;comment:报告编号"`
	TzID         uint             `json:"tz_id" gorm:"column:tz_id;comment:体质ID"`
	JqID         uint             `json:"jq_id" gorm:"column:jq_id;comment:节气ID"`
	BzlxIDs      string           `json:"bzlx_ids" gorm:"column:bzlx_ids;comment:病症类型"`
	BzIDs        string           `json:"bz_ids" gorm:"column:bz_ids;comment:病症"`
	User         *user.User       `json:"-" form:"-" gorm:"->;foreignKey:Uid;references:ID;"`   // 关联用户
	Physique     *health.Physique `json:"-" form:"-" gorm:"->;foreignKey:TzID;references:ID;"`  // 关联体质
	SolarTerms   *health.FdJq     `json:"-" form:"-" gorm:"->;foreignKey:JqID;references:ID;"`  // 关联节气
	Disease      *health.Disease  `json:"-" form:"-" gorm:"->;foreignKey:BzIDs;references:ID;"` // 关联病症
}

// DiseaseReportPlan 病症报告方案struct
type DiseaseReportPlan struct {
	global.GVA_MODEL
	DrrID       uint   `json:"drr_id" gorm:"column:drr_id;comment:病症报告记录ID"`
	Types       int    `json:"types" gorm:"column:types;comment:1脑波方案2运动方案3体质茶 4您的配餐 5千预方案"`
	IDs         string `json:"ids" gorm:"column:ids;comment:文章方案"`
	ArticleType int    `json:"article_types" gorm:"column:article_types;comment:文章类型 1图文2音频 3视频"`
	Content     string `json:"content" gorm:"column:content;comment:干预方案;type:text"`
	Money       uint   `json:"money" gorm:"column:money;comment:金额"`
}

type User struct {
	global.GVA_MODEL
	Points       uint      `json:"points" gorm:"column:points;default:0;comment:积分"`
	InviteUserID uint      `json:"invite_user_id" gorm:"column:invite_user_id;comment:邀请人id"`
	Phone        string    `json:"phone" gorm:"column:phone;comment:用户手机号"`
	Name         string    `json:"name" form:"name" gorm:"column:name;comment:名称"`
	Avatar       string    `json:"avatar" gorm:"column:avatar;default:http://cush.cushdylm.com/uploads/20211019/7539DDDD6AAF99276040515309AC5F65.jpg;comment:用户头像"`
	Types        uint      `json:"types" gorm:"column:types;default:1;comment:用户类型 1用户 2会员 3过期会员"`
	Sex          uint      `json:"sex" gorm:"column:sex;default:1;comment:性别 1男 2女"`
	Birthday     time.Time `json:"birthday" gorm:"column:birthday;comment:生日"`
	Physique     uint      `json:"physique" gorm:"->;column:physique;comment:体质"`
	Grade        bool      `json:"grade" gorm:"column:grade;default:false;comment:是否是会员"`
}

type OpenLog struct {
	OpID           uint      `json:"opID" gorm:"column:op_id;comment:开通者ID"`
	UID            string    `json:"uid" gorm:"column:uid;comment:用户ID"`
	OpenPersonType uint      `json:"openPersonType" gorm:"column:open_person_type;comment:1服务站2健管师3用户"`
	OpenType       uint      `json:"openType" gorm:"column:open_type;comment:1会员2普通"`
	CreatedAt      time.Time // 创建时间
}

func (User) TableName() string {
	return "fd_user"
}

func (DiseaseType) TableName() string {
	return "fd_bzlx"
}

func (Disease) TableName() string {
	return "fd_bz"
}

func (DiseaseReportRecord) TableName() string {
	return "fd_disease_report_record"
}

func (DiseaseReportPlan) TableName() string {
	return "fd_disease_report_plan"
}
